home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / acp3.00 / acpcycle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-18  |  5.8 KB  |  260 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3. #include <graphics/gfxbase.h>
  4. #include "includes/AcpCycle_protos.h"
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <clib/intuition_protos.h>
  9. #include <clib/graphics_protos.h>
  10. extern struct Window *EWin;
  11. extern int Theight;
  12. char LastUsers[6][44];
  13. char LastUploads[6][44];
  14. char LastDownloads[6][44];
  15. struct NodeUsers
  16. {
  17.   char LastUsers[6][44];
  18.   int num;
  19. } NdUser[10],NdUploads[10],NdDownloads[10];
  20. char LastBlank[]="                               ";
  21. void RegLastUser(char *name,int node)
  22. {
  23.   register int i=0;
  24.   static int num=0;
  25.   RegNodeUser(name,node);
  26.   if(num>0 && num<5)
  27.   {
  28.   if(!strcmp(LastUsers[num-1],name))
  29.     return;
  30.   }
  31.   if(num==5)
  32.   {
  33.     while(i<4)
  34.     {
  35.       strcpy(LastUsers[i],LastUsers[i+1]);
  36.       i++;
  37.     }
  38.     num =4;
  39.     strcpy(LastUsers[num],name); 
  40.     
  41.   } else strcpy(LastUsers[num],name);
  42.   num +=1; 
  43. }
  44. void RegNodeUser(char *name,int node)
  45. {
  46.   register int i=0;
  47.   if(NdUser[node].num>0 && NdUser[node].num<5)
  48.   {
  49.   if(!strcmp(NdUser[node].LastUsers[NdUser[node].num-1],name))
  50.     return;
  51.   }
  52.   if(NdUser[node].num==5)
  53.   {
  54.     while(i<4)
  55.     {
  56.       strcpy(NdUser[node].LastUsers[i],NdUser[node].LastUsers[i+1]);
  57.       i++;
  58.     }
  59.     NdUser[node].num =4;
  60.     strcpy(NdUser[node].LastUsers[NdUser[node].num],name); 
  61.     
  62.   } else strcpy(NdUser[node].LastUsers[NdUser[node].num],name);
  63.   NdUser[node].num +=1; 
  64. }
  65.    
  66. void ShowLastUser(struct Window *Win)
  67. {
  68.    register int i=0;
  69.    SetAPen(Win->RPort,1);
  70.    while(i<5)
  71.    {
  72.       PrintMyText(Win->RPort,&LastBlank,340,155+(i*10)-110+(Theight*11));
  73.       PrintMyText(Win->RPort,&LastUsers[i][0],340,155+(i*10)-110+(Theight*11));
  74.       i++;
  75.    }
  76. }
  77. void ShowNdLastUser(struct Window *Win,int node)
  78. {
  79.    register int i=0;
  80.    SetAPen(Win->RPort,1);
  81.    while(i<5)
  82.    {
  83.       PrintMyText(Win->RPort,LastBlank,340,155+(i*10)-110+(Theight*11));
  84.       PrintMyText(Win->RPort,NdUser[node].LastUsers[i],340,155+(i*10)-110+(Theight*11));
  85.       i++;
  86.    }
  87. }
  88. void RegLastUploads(char *name,int node)
  89. {
  90.   register int i=0;
  91.   static int num=0;
  92.   RegNodeUploads(name,node);
  93.   if(num>0 && num<5)
  94.   {
  95.   if(!strcmp(LastUploads[num-1],name))
  96.     return;
  97.   }
  98.   if(num==5)
  99.   {
  100.     while(i<4)
  101.     {
  102.       strcpy(LastUploads[i],LastUploads[i+1]);
  103.       i++;
  104.     }
  105.     num =4;
  106.     strcpy(LastUploads[num],name); 
  107.     
  108.   } else strcpy(LastUploads[num],name);
  109.   num +=1; 
  110. }
  111. void RegNodeUploads(char *name,int node)
  112. {
  113.   register int i=0;
  114.   if(NdUploads[node].num>0 && NdUploads[node].num<5)
  115.   {
  116.   if(!strcmp(NdUploads[node].LastUsers[NdUploads[node].num-1],name))
  117.     return;
  118.   }
  119.   if(NdUploads[node].num==5)
  120.   {
  121.     while(i<4)
  122.     {
  123.       strcpy(NdUploads[node].LastUsers[i],NdUploads[node].LastUsers[i+1]);
  124.       i++;
  125.     }
  126.     NdUploads[node].num =4;
  127.     strcpy(NdUploads[node].LastUsers[NdUploads[node].num],name); 
  128.     
  129.   } else strcpy(NdUploads[node].LastUsers[NdUploads[node].num],name);
  130.   NdUploads[node].num +=1; 
  131. }
  132.    
  133. void ShowLastUploads(struct Window *Win)
  134. {
  135.    register int i=0;
  136.    SetAPen(Win->RPort,1);
  137.    while(i<5)
  138.    {
  139.       PrintMyText(Win->RPort,LastBlank,340,155+(i*10)-110+(Theight*11));
  140.       PrintMyText(Win->RPort,LastUploads[i],340,155+(i*10)-110+(Theight*11));
  141.       i++;
  142.    }
  143. }
  144. void ShowNdLastUploads(struct Window *Win,int node)
  145. {
  146.    register int i=0;
  147.    SetAPen(Win->RPort,1);
  148.    while(i<5)
  149.    {
  150.       PrintMyText(Win->RPort,LastBlank,340,155+(i*10)-110+(Theight*11));
  151.       PrintMyText(Win->RPort,NdUploads[node].LastUsers[i],340,155+(i*10)-110+(Theight*11));
  152.       i++;
  153.    }
  154. }
  155. void RegLastDownloads(char *name,int node)
  156. {
  157.   register int i=0;
  158.   static int num=0;
  159.   RegNodeDownloads(name,node);
  160.   if(num>0 && num<5)
  161.   {
  162.   if(!strcmp(LastDownloads[num-1],name))
  163.     return;
  164.   }
  165.   if(num==5)
  166.   {
  167.     while(i<4)
  168.     {
  169.       strcpy(LastDownloads[i],LastDownloads[i+1]);
  170.       i++;
  171.     }
  172.     num =4;
  173.     strcpy(LastDownloads[num],name); 
  174.     
  175.   } else strcpy(LastDownloads[num],name);
  176.   num +=1; 
  177. }
  178. void RegNodeDownloads(char *name,int node)
  179. {
  180.   register int i=0;
  181.   if(NdDownloads[node].num>0 && NdDownloads[node].num<5)
  182.   {
  183.   if(!strcmp(NdDownloads[node].LastUsers[NdDownloads[node].num-1],name))
  184.     return;
  185.   }
  186.   if(NdDownloads[node].num==5)
  187.   {
  188.     while(i<4)
  189.     {
  190.  
  191. strcpy(NdDownloads[node].LastUsers[i],NdDownloads[node].LastUsers[i+1]);
  192.       i++;
  193.     }
  194.     NdDownloads[node].num =4;
  195.     strcpy(NdDownloads[node].LastUsers[NdDownloads[node].num],name); 
  196.     
  197.   } else strcpy(NdDownloads[node].LastUsers[NdDownloads[node].num],name);
  198.   NdDownloads[node].num +=1; 
  199. }
  200.    
  201. void ShowLastDownloads(struct Window *Win)
  202. {
  203.    register int i=0;
  204.    SetAPen(Win->RPort,1);
  205.    while(i<5)
  206.    {
  207.       PrintMyText(Win->RPort,LastBlank,340,155+(i*10)-110+(Theight*11));
  208.       PrintMyText(Win->RPort,FilePart(LastDownloads[i]),340,155+(i*10)-110+(Theight*11));
  209.       i++;
  210.    }
  211. }
  212. void ShowNdLastDownloads(struct Window *Win,int node)
  213. {
  214.    register int i=0;
  215.    SetAPen(Win->RPort,1);
  216.    while(i<5)
  217.    {
  218.       PrintMyText(Win->RPort,LastBlank,340,155+(i*10)-110+(Theight*11));
  219.  
  220. PrintMyText(Win->RPort,FilePart(NdDownloads[node].LastUsers[i]),340,155+(i*10)-110+(Theight*11));
  221.       i++;
  222.    }
  223. }
  224.  
  225. void InitCycles(void)
  226. {
  227.   register int i;
  228.   for(i=0;i<5;i++)
  229.   {
  230.     strcpy(LastUsers[i],"                               ");
  231.     strcpy(LastUploads[i],&LastUsers[i]);
  232.     strcpy(LastDownloads[i],&LastUsers[i]);
  233.   }
  234.   InitNdCycles();
  235. }
  236.  
  237. void InitNdCycles(void)
  238. {
  239.   register int i,x;
  240.   for(x=0;x<9;x++)
  241.   {
  242.     for(i=0;i<5;i++)
  243.     {
  244.       strcpy(NdUser[x].LastUsers[i],"                               ");
  245.       strcpy(NdUploads[x].LastUsers[i],"                               ");
  246.       strcpy(NdDownloads[x].LastUsers[i],"                               ");
  247.     }
  248.     NdUser[x].num=0;
  249.     NdUploads[x].num=0;
  250.     NdDownloads[x].num=0;
  251.   }
  252.    
  253. }
  254. struct IntuiText t = {
  255.   3,0,JAM2,0,0,NULL,NULL,NULL };
  256. void PrintMyText(struct RastPort *RPort,char *text,int x,int y)
  257. {
  258.   t.IText=(UBYTE *)text;
  259.   PrintIText(RPort,(struct IntuiText *)&t,x,y-6);
  260. }